package com.sentinel.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class HelloService {
    @SentinelResource(value = "sayHi1",blockHandler = "sayHi1Error")
    public String sayHi(String name) throws InterruptedException {
        String result = "hello sentinel i am" + name;
        Thread.sleep(200);
        return result;
    }
    public String sayHi1Error(String name, BlockException ex){
        log.info("当前BlockException异常类型：{}",ex.getClass().getName());
        return "熔断发生了,业务资源无法调用";
    }
}
